require 'rubygems'
require 'google_chart'
    
module TourGroupsControllerHelper
  def number_to_rmb(number)
    number_to_currency number, :unit => "￥", :precision => 0
  end
  
  def duration(during_start, during_end)
    return during_start if during_start != nil && during_end == nil
    return "至 " + during_end.strftime if during_start == nil && during_end != nil
    if during_start != nil && during_end != nil
      duration_text = during_start.strftime + " 至 "
      return duration_text + during_end.strftime("%d") if during_start.year == during_end.year && during_start.month == during_end.month
      return duration_text + during_end.strftime("%m-%d") if during_start.year == during_end.year
      return duration_text + during_end.strftime
    end
  end
  
  def pie_chart
    GoogleChart::PieChart.new('320x200', "Pie Chart",false) do |pc|
      pc.data "very good", 300
      pc.data "good", 200
      pc.data "just so so", 100
      pc.data "bad", 180
      pc.show_labels = true
      return pc.to_url
    end
  end

end
